package com.itheima.service.impl;

import com.itheima.common.entity.Result;
import com.itheima.common.utils.SmsUtil;
import com.itheima.mapper.ValidateCodeMapper;
import com.itheima.service.ValidateCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.itheima.common.utils.SmsUtil.sendVerificationCode;

@Service
@Slf4j
public class ValidateCodeServiceImpl implements ValidateCodeService {

    @Autowired
    ValidateCodeMapper validateCodeMapper;

    @Autowired
    private SmsUtil smsUtil;

    @Override
    public Result ValidateCode(String telephone) {
        if(validateCodeMapper.existTelephone(telephone)==null){
           log.info("用户不存在");
            return new Result(false,"用户不存在");
        }
        String phoneNumber = "13800001111"; // 替换为测试手机号
        String signName = "阿里云短信测试";   // 替换为你审核通过的签名
        String templateCode = "SMS_123456789"; // 替换为你审核通过的模板CODE
        boolean sent = sendVerificationCode(phoneNumber, signName, templateCode);
        return new Result(false,"验证码发送成功");
    }
}
